package com.itheima.d6_generics_class;

import com.itheima.d6_generics_class.bean.Cat;
import com.itheima.d6_generics_class.bean.Dog;

public class Result {
    int code; //代码
    String msg; //描述
    Object data; //可以是任何数据，结果包含的数据
}

class Result2<T>{
    int code; //代码
    String msg; //描述
    T data; //可以是任何数据，结果包含的数据
}

class Demo{
    public static void main(String[] args) {
        Result r1 = new Result();
        r1.code = 200;
        r1.msg = "请求数据正常";
//        r1.data = new Cat();
        r1.data = new Dog();

        Object data = r1.data;

        Result2<Cat> r2 = new Result2<>();
        r2.code = 200;
        r2.msg = "";
        r2.data = new Cat();
//        r2.data = new Dog(); //报错

        Cat data2 = r2.data;
    }
}

